//
//  HomePageViewController.m
//  MyYiJianKangApp
//
//  Created by 张国文 on 16/3/29.
//  Copyright © 2016年 hangzhouyijiyin. All rights reserved.
//

#import "HomePageViewController.h"
#import <AFNetworking.h>
#import "NetStatusHandle.h"

@interface HomePageViewController ()

@end

@implementation HomePageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"首页";
    [self netStatus];
}

// 判断网络状态
- (void)netStatus
{
    AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager];
    [manager startMonitoring];
    [manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        // AFNetworkReachabilityStatusUnknown          = -1, // 不可知
        //        AFNetworkReachabilityStatusNotReachable     = 0, // 无网络
        //        AFNetworkReachabilityStatusReachableViaWWAN = 1, // 2d或者3d
        //        AFNetworkReachabilityStatusReachableViaWiFi = 2, // wifi
        NetStatusHandle *handle = [NetStatusHandle shareHandle];
        if (status == 0) {
            // 无网络
            NSLog(@"没有网络");
            [handle saveNetStatus:@"NO"];
        } else {
            // 有网络
            NSLog(@"有网络");
            [handle saveNetStatus:@"YES"];
        }
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
